package com.yict.common.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;

/**
 * 
 * @author Jay.Wu
 * 
 */
public class LogUtil {

	protected static Logger logger;

	public static Logger getLogger(Class<?> clazz) {
		logger = LoggerFactory.getLogger(clazz);
		return logger;
	}

	public static void put(String key, String val) {
		MDC.put(key, val);
	}

	public static void clear() {
		MDC.clear();
	}

	public static String errorException(Exception e) {
		StackTraceElement[] ste = e.getStackTrace();
		StringBuffer sb = new StringBuffer();
		sb.append(e.getMessage() + "n");
		
		for (int i = 0; i < ste.length; i++) {
			sb.append(ste[i].toString() + "n");
		}
		
		return sb.toString();
	}
}